﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _plants_vs_zombies
{
    class Sun
    {
        /// <summary>
        /// 定义sun的rectangle
        /// </summary>
        public Rectangle Rectangle { get; set; }

        /// <summary>
        /// 定义sun的存活到点时间
        /// </summary>
        public DateTime DeadTime { get; set; }

        /// <summary>
        /// sun的下落速度
        /// </summary>
        private const int Speed = 8;

        /// <summary>
        /// 定义sun的移动属性有无
        /// </summary>
        private bool moveable { get; set; }


        /// <summary>
        /// 多态
        /// </summary>
        /// <param name="rec"></param>
        public Sun(Rectangle rec)
        {
            //定义sun的存活时间
            DeadTime = System.DateTime.Now.AddSeconds(5);
            Rectangle = rec;
            moveable = true;      
        }

        /// <summary>
        /// 多态
        /// </summary>
        /// <param name="rec"></param>
        /// <param name="_moveable"></param>
        public Sun(Rectangle rec,bool _moveable)
        {
            //定义sun的存活时间
            DeadTime = System.DateTime.Now.AddSeconds(5);
            Rectangle = rec;
            moveable = _moveable;
        }

        /// <summary>
        /// 绘制sun
        /// </summary>
        /// <param name="g"></param>
        public void Draw(Graphics g)
        {
            g.DrawImage(Properties.Resources.太阳, Rectangle);
              
        }

        /// <summary>
        /// sun的移动函数
        /// </summary>
        public void Move()
        {
            if (moveable)
                this.Rectangle = new Rectangle(Rectangle.X, Rectangle.Y+Speed, Rectangle.Width, Rectangle.Height);          
        }
    }
}
